/*
 * Filename:    IntegrityLevelSetDao.java
 * Copyright:   2015 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2015-3-17
 */
package com.paic.mhis.hcpms.trust.intergration.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.paic.mhis.hcpms.trust.dto.IntegrityIllegalDTO;
import com.paic.mhis.hcpms.trust.dto.IntegrityLevalSetMiddleDTO;
import com.paic.mhis.hcpms.trust.dto.IntegrityLevelDTO;
import com.paic.pafa.biz.dao.BaseDAO;

/**
 * 诚信管理中关注级别和违规情节的dao
 * 
 * @author EX-WANGKUI001
 * 
 */
@Component("integrityLevelSetDao")
public class IntegrityLevelSetDao extends BaseDAO {

	public void deleteLevelAndIlleaglMid(String levelId, String illegalId) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("levalId", levelId);
		map.put("illegalId", illegalId);

		this._delete("integritylevelSet.deleteInteLevelMid", map);

	}

	public void deleteIllegalInfo(String illegalId) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("id", illegalId);
		this._delete("integritylevelSet.deleteInteIllegalInfo", map);

	}

	/**
	 * 加载对应的关注级别信息
	 * 
	 * @param parameter
	 * @return
	 */
	public List<IntegrityLevelDTO> loadIntegrityLevelDTO(Map<String, Object> parameter) {

		List<IntegrityLevelDTO> list = (List<IntegrityLevelDTO>) this._queryForList(
				"integritylevelSet.loadLevelDataInfo", parameter);

		return list;

	}

	public long loadIntegrityLevelDTOCount(Map<String, Object> parameter) {
		long count = this._queryForCount("integritylevelSet.loadLevelDataInfoCount", parameter);
		return count;
	}

	/**
	 * 根据对应的关注级别Id 加载对应的违规情节
	 * 
	 * @param levelId
	 * @return
	 */
	public List<IntegrityIllegalDTO> loadIntegrityIllegalDTOByLevelId(String levelId) {

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("levelId", levelId);

		List<IntegrityIllegalDTO> list = (List<IntegrityIllegalDTO>) this._queryForList(
				"integritylevelSet.loadIllegalInfoByLevelId", map);

		return list;

	}

	/**
	 * 保存对应的违规情节对象
	 * 
	 * @param legalDTO
	 */
	public void saveIntegrityIllealBean(IntegrityIllegalDTO legalDTO) {

		this._insert("integritylevelSet.insertIllegalInfo", legalDTO);

	}

	/**
	 * 保存对应的级别和违规情节的中间表信息
	 * 
	 * @param bean
	 */
	public void saveIntegrityLevalSetMiddleDTO(IntegrityLevalSetMiddleDTO bean) {
		this._insert("integritylevelSet.insertInteLevelMid", bean);

	}

	/**
	 * 判断当前的违规情节是否已经被使用了
	 * 
	 * @param bean
	 * @return
	 */
	public boolean checkIntegrityLevelIsExist(String levelId, String illegalId) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("levelId", levelId);
		map.put("illegalId", illegalId);
		long count = this._queryForCount("integritylevelSet.checkIntegrityMid", map);

		if (count > 0) {
			return true;
		} else {
			return false;
		}

	}

	/***
	 * 修改对应的违规情节对象
	 * 
	 * @param legalDTO
	 */
	public void updateHcpmsInteIllegalById(IntegrityIllegalDTO legalDTO) {
		this._update("updateHcpmsInteIllegalById", legalDTO);
	}
}
